// "use strict";
import Vue from 'vue'
import C from './cfg'
import util from './util'
import msgTimer from './MsgTimer'
import testData from './testData'
import {Message} from 'element-ui';
import {Notification} from 'element-ui';
import NProgress from 'nprogress'


function getTestData(key) {
 return new Promise(function (fulfil, reject) {
 let td = testData[key]
 if(!td){
   console.log(`缺少数据 ${key}`)
   td = {"retCode": 200,
   "retMsg": "Success!"}
 }
 let res = dataStandard({body: td})
 res.FX = {err: false, ok: true}
 setTimeout(fulfil(res), 1000);
 //fulfil(dataStandard({body: testData[key]}));
 });
 }
function dataStandard(res) {
  NProgress.done();
  if (res.body.count != null) res.body.count = parseInt(res.body.count);
  if (res.body.page_sizes != null) res.body.page_sizes = parseInt(res.body.page_sizes);
  if (res.body.page_count != null) res.body.page_count = parseInt(res.body.page_count);
  if (res.body.currentPage != null) res.body.currentPage = parseInt(res.body.currentPage);
  return res;

}
/**
 * 请求错误提示
 */
class errorTips {
  constructor() {
    // this.Authentication = ""
  }
}

class Dao {
  constructor() {
    // this.Authentication = ""
  }

  getHeaders() {
    C.HEADERS.RJDATACENTERID = `${util.fetch('dataCenterId')||10000}`;
    C.HEADERS.Authentication = `Basic ${util.fetch("token")}`;
  }

  /**
   * 请求
   * @param url 请求url
   * @param body 参数
   * @param opts {type:为了有假数据也能访问真实数据 1 真实||0 用假数据}
   * @returns {Promise.<T>}
   */
  vPost(url, body, opts) {
    NProgress.start();
    opts || (opts = {});
    this.getHeaders();

    let key = url.replace(`${C.APIURL}`, "");
    util.requset_before(body);
    /* opts.type = ((opts.type == 2) ? 0 : 1);
     if (C.DEV == "test" && !opts.type && testData[key]) return getTestData(key);
     else */

    return getTestData(key)

    return Vue.http.post(url, body, {
      headers: C.HEADERS,
      _timeout: 15000,
      onTimeout: (request) => {
        NProgress.done();
        Message({
          type: 'error',
          message: `请求超时`
        });
      }
    }).then(res => {
      if (!res.body || res.body.retCode != '200') {
        let errTips = "";
        if (C.RESPONSE_WORK_BOOK[res.body.retCode]) {
          errTips = C.RESPONSE_WORK_BOOK[res.body.retCode].tips;
        }/*else if(res.status){
         errTips = C.RESPONSE_WORK_BOOK[res.status].tips;
         }*/ else {
          errTips = res.body.retMsg || "";
        }
        msgTimer.alert({
          title: '提示',
          message: `${res.body.retCode}:${errTips} ${key}`,
        });
      }
      return dataStandard(res)

    }).catch(res => {

      NProgress.done();
      let errTips = "";
      if (res.body && res.body.retCode) {
        errTips = C.RESPONSE_WORK_BOOK[res.body.retCode].tips;
      } else {
        errTips = "其他错误类型";
      }
      msgTimer.alert({
        title: '错误提示',
        message: `${res.status} ${errTips}`,
      });
      return res

    })
  }

  /**
   * 1.1.1.1 登录
   * @param body
   * @returns {*}
   */
  login(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/login2`, body);
  }
  logout(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/logout`, body);
  }
  captcha(body){
    // return this.vPost(`${C.APIURL}bdpmng/service/user/captcha`, body);
    let url = `${C.APIURL}bdpmng/service/user/captcha`;
    return Vue.http.post(url, body, {
      headers: C.HEADERS,
      _timeout: 3000,
      onTimeout: (request) => {
        Message({
          type: 'error',
          message: `请求超时`
        });
      }
    })
  }

  expireUpdatePasswd(body){
    return this.vPost(`${C.APIURL}bdpmng/service/user/expireUpdatePasswd`, body);
  }

  /**
   * 1.2.1.2  下载keytab
   * @param body
   * @returns {string}
   */
  genKeyTab(body) {
    /*let a = `${C.APIURL}bdpmng/service/kerberos/genKeyTab?token=${util.getCookie("token")}`;
     window.open(a);
     return 0;*/
    let url = `${C.APIURL}bdpmng/service/kerberos/genKeyTab`;
    Vue.http.get(url, {
      headers: C.HEADERS,
      _timeout: 3000,
      onTimeout: (request) => {
        Message({
          type: 'error',
          message: `请求超时`
        });
      }
    }).then(res => {
      if (res.body.type != 'application/zip') {
        Message({
          type: 'error',
          message: res.body.retMsg
        });
        return false;
      }
      util.downloadFile('keyTab.zip', res.body)
    });
  }

  /**
   * 1.2.1.1 获取用户信息
   * @param body
   * @returns {*}
   */
  getUserInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/getUserInfo`, body);
  }

  getUserTenantInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/getUserTenantInfo`, body);
  }

  /**
   * 1.2.1.3  查询系统菜单
   * @param body
   * @returns {*}
   */
  getMenu(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/getMenu`, body,);
  }

  /**
   * 1.2.1.4  登录用户修改密码
   * @returns {*}
   */
  updatePasswd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/updatePasswd`, body);
  }

  // begin 平台监控接口个
  /**
   * 2.1.1.1  任务分段分类统计
   * @param body
   * @returns {*}
   */
  getAppsState(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getAppsState`, body);
  }

  /**
   * 2.1.1.2  激活节点[Active Node]
   * @param body
   * @returns {*}
   */
  getActiveNodes(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getActiveNodes`, body);
  }

  /**
   * 2.1.1.3  集群可用内存
   * @param body
   * @returns {Promise.<T>}
   */
  getMemoryUsage(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getMemoryUsage`, body);
  }

  /**
   * 2.1.1.6  RegionServer数量
   * @param body
   * @returns {Promise.<T>}
   */
  getOnlineRegionServer(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getOnlineRegionServer`, body);
  }

  /**
   * 2.1.1.7  DataNodes存活量
   * @param body
   * @returns {Promise.<T>}
   */
  getDataNodes(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getDataNodes`, body);
  }

  /**
   * 2.1.1.8  Region数量
   * @param body
   * @returns {Promise.<T>}
   */
  getClusterRegions(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getClusterRegions`, body);
  }

  /**
   * 2.1.1.9  HIVE DataBase数量
   * @param body
   * @returns {Promise.<T>}
   */
  getHiveDBs(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHiveDBs`, body);
  }

  /**
   * 2.1.1.10  HIVE 表数量
   * @param body
   * @returns {Promise.<T>}
   */
  getHiveTables(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHiveTables`, body);
  }

  /**
   * 2.1.1.11  HIVE 分区数量
   * @param body
   * @returns {Promise.<T>}
   */
  getHivePartitions(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHivePartitions`, body);
  }

  /**
   * 2.1.1.12  HDFS LOAD TOTAL(HDFS负载总量)
   * @param body
   * @returns {Promise.<T>}
   */
  getHdfsLoadTotal(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHdfsLoadTotal`, body);
  }

  /**
   * 2.1.1.13  HDFS 存储空间
   * @param body
   * @returns {Promise.<T>}
   */
  getHdfsCapacityInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHdfsCapacityInfo`, body);
  }

  /**
   * 2.1.1.14  RegionServer 内存分布
   * @param body
   * @returns {Promise.<T>}
   */
  getHbaseRegionServerMemsLayout(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHbaseRegionServerMemsLayout`, body);
  }

  /**
   * 2.1.1.15  RegionServer RPC
   * @param body
   * @returns {Promise.<T>}
   */
  getHbaseRegionServerRpc(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHbaseRegionServerRpc`, body);
  }

  /**
   * 2.1.1.16  KAFKA 输入输出字节数
   * @param body
   * @returns {Promise.<T>}
   */
  getKafkaBytesInOrOutPerSec(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getKafkaBytesInOrOutPerSec`, body);
  }

  /**
   * 2.1.1.17  KAFKA 消息数
   * @param body
   * @returns {Promise.<T>}
   */
  getKafkaMessagesInPerSec(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getKafkaMessagesInPerSec`, body);
  }

  /**
   * 2.1.1.18  CPU 信息
   * @param body
   * @returns {Promise.<T>}
   */
  getCPUUsage(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getCPUUsage`, body);
  }

  /**
   * 2.1.1.19 DataNotes Live
   * @param body
   * @returns {Promise.<T>}
   */
  getHdfsCapacity(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHdfsCapacity`, body);
  }

  /**
   * 2.1.1.20 Yarn 内存
   *  @param body
   * @returns {Promise.<T>}
   */
  getYARNMemory(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getYARNMemory`, body);
  }

  /**
   * 2.1.1.21 YARN Node Manger存活量
   *  @param body
   * @returns {Promise.<T>}
   */
  getNodeManagers(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getNodeManagers`, body);
  }

  /**
   * 2.1.1.22 HDFS 表数量
   *  @param body
   * @returns {Promise.<T>}
   */
  getHbaseTables(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/monitor/getHbaseTables`, body);
  }


  // end 平台监控接口个

  /**
   * 2.1.1.3 查询组件信息
   * @param body
   * @returns {*}
   */
  getAssemblys(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/getAssemblys`, body);
  }

  //请求租户管理-首页-列表信息
  getTenantInfoList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/getTenantInfoList`, body);
  }

  /**
   * 2.1.1.2  查询数据中心列表
   * @param body
   * @returns {*}
   */
  getDataCenterList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/getDataCenterList`, body);
  }

  /**
   * 2.1.1.3  查询组件信息
   * @param body
   * @returns {*}
   */
  getAssemblys(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/getAssemblys`, body);
  }

  /**
   * 2.1.1.4  验证租户是否存在
   * @param body
   * @returns {*}
   */
  getValidateTenant(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/validateTenant`, body);
  }

  /**
   * 2.1.1.5  创建租户
   * @param body
   * @returns {*}
   */
  getAddTenantInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/addTenantInfo`, body);
  }

  /**
   * 2.1.1.6  修改租户
   * @param body
   * @returns {*}
   */
  getUpdateTenantInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/updateTenantInfo`, body);
  }

  /**
   * 2.1.1.7  删除租户
   * @param body
   * @returns {*}
   */
  getDeleteTenantBatch(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/deleteTenantBatch`, body);
  }

  /**
   * 2.1.1.8  查询hdfs
   * @param body
   * @returns {*}
   */
  getHdfsInfoList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hdfs/get`, body);
  }

  /**
   * 2.1.1.9  查询Yarn
   * @param body
   * @returns {*}
   */
  getYarnInfoList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/yarn/get`, body);
  }

  /**
   * 2.1.1.11  查询Hbase
   * @param body
   * @returns {*}
   */
  getHbaseInfoList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hbase/get`, body);
  }

  /**
   * 2.1.1.12  查询Kafka
   * @param body
   * @returns {*}
   */
  getKafkaInfoList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/kafka/get`, body);
  }

  /**
   * 2.1.1.10  查询Hive
   * @param body
   * @returns {*}
   */
  getHiveInfoList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hive/get`, body);
  }

  /**
   * 2.1.2.1  增加hdfs
   * @param body
   * @returns {*}
   */
  addHdfs(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hdfs/add`, body);
  }

  /**
   * 2.1.2.2  增加hdfs
   * @param body
   * @returns {*}
   */
  addHbase(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hbase/add`, body);
  }

  /**
   * 2.1.2.3  增加hdfs
   * @param body
   * @returns {*}
   */
  addHive(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hive/add`, body);
  }

  /**
   * 2.1.2.4  增加yarn
   * @param body
   * @returns {*}
   */
  addYarn(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/yarn/add`, body);
  }

  /**
   * 2.1.2.5 增加kafka
   * @param body
   * @returns {*}
   */
  addKafka(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/kafka/add`, body);
  }

  /**
   * 3.1.2.1  更新hdfs
   * @param body
   * @returns {*}
   */
  updateHdfs(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hdfs/update`, body);
  }

  /**
   * 3.1.2.2  更新Hbase
   * @param body
   * @returns {*}
   */
  updateHbase(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hbase/update`, body);
  }


  /**
   * 3.1.2.3  更新Hive
   * @param body
   * @returns {*}
   */
  updateHive(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hive/update`, body);
  }

  /**
   * 3.1.2.4  更新yarn
   * @param body
   * @returns {*}
   */
  updateYarn(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/yarn/update`, body);
  }

  /**
   * 3.1.2.5  更新kafka
   * @param body
   * @returns {*}
   */
  updateKafka(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/kafka/update`, body);
  }

  /**
   * 3.1.2.1  增加hdfs
   * @param body
   * @returns {*}
   */
  deleteHdfs(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hdfs/delete`, body);
  }

  /**
   * 3.1.2.2  增加Hbase
   * @param body
   * @returns {*}
   */
  deleteHbase(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hbase/delete`, body);
  }

  /**
   * 3.1.2.3  删除Hive
   * @param body
   * @returns {*}
   */
  deleteHive(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/hive/delete`, body);
  }

  /**
   * 3.1.2.4  删除yarn
   * @param body
   * @returns {*}
   */
  deleteYarn(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/yarn/delete`, body);
  }

  /**
   * 3.1.2.5 删除kafka
   * @param body
   * @returns {*}
   */
  deleteKafka(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tenant/kafka/delete`, body);
  }

  getLogByTaskId(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/tasktbl/getLog`, body);
  }

  webshellShell(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/webshell/shell`, body);
  }


  /**
   * 3.1.1.1  查询用户的hdfs资源列表
   * @param body
   * @returns {Promise.<T>}
   */
  getHdfsList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/hdfs/getHdfsList`, body);
  }

  /**
   * 3.1.1.2  查询或刷新目录
   * @param body
   * @returns {Promise.<T>}
   */
  findByPath(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/findByPath`, body);
  }

  /**
   * 查询HDFS路径
   * @param body
   * @returns {Promise.<T>}
   */
  findByPathHdfs(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hdfs/policy/findByPath`, body);
  }

  /**
   * 获取HIVE数据库列表
   * @param body
   * @returns {Promise.<T>}
   */
  getHiveDB(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hive/policy/getHiveDBS`, body);
  }


  /**
   * 3.1.1.3  查询搜索文件名
   * @param body
   * @returns {Promise.<T>}
   */
  findByName(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/findByName`, body);
  }

  /**
   * 3.1.1.4  创建目录
   * @param body
   * @returns {Promise.<T>}
   */
  mkdir(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/mkdir`, body);
  }

  /**
   * 3.1.1.5  上传文件
   * @param body
   * @returns {Promise.<T>}
   */
  upload(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/upload`, body);
  }

  /**
   * 3.1.1.6  下载文件
   * @param body
   * @returns {Promise.<T>}
   */
  download(params) {
    // let a = `${C.APIURL}bdpmng/service/datamgt/hdfs/download?token=${util.getCookie("token")}&hdfs_path=${downfile}`;
    // window.open(a);

    Vue.http.get(`${C.APIURL}bdpmng/service/datamgt/hdfs/download`, {
      headers: C.HEADERS,
      params: params,
      _timeout: 3000,
      onTimeout: (request) => {
        Message({
          type: 'error',
          message: `请求超时`
        });
      }
    }).then(res => {
      if (res.body.type != 'application/octet-stream') return false;
      let dirs = params.hdfs_path.split('/');
      util.downloadFile(dirs[dirs.length - 1], res.body)
    }).catch(res => {
      NProgress.done();
      Notification.error({
        title: '错误提示',
        message: `HTTP错误码:${res.status}`,
      });
      return res
    })
    // return 0;
  }

  /**
   * 3.1.1.7  合并文件
   * @param body
   * @returns {Promise.<T>}
   */
  concatFiles(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/concatFiles`, body);
  }

  /**
   * 3.1.1.8  查看文件内容
   * @param body
   * @returns {Promise.<T>}
   */
  readFile(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/readFile`, body);
  }

  /**
   * 3.1.1.9  重命名文件或文件夹
   * @param body
   * @returns {Promise.<T>}
   */
  renameFile(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/renameFile`, body);
  }

  /**
   * 3.1.1.10 删除文件或文件夹
   * @param body
   * @returns {Promise.<T>}
   */
  deleteFile(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/deleteFile`, body);
  }

  /**
   * 3.1.1.11 移动文件或文件夹
   * @param body
   * @returns {Promise.<T>}
   */
  moveFile(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/moveFile`, body);
  }

  /**
   * 3.1.1.12 创建快照
   * @param body
   * @returns {Promise.<T>}
   */
  createSnapshot(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/createSnapshot`, body);
  }

  /**
   * 3.1.1.13 恢复快照
   * @param body
   * @returns {Promise.<T>}
   */
  restoreSnapshot(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/restoreSnapshot`, body);
  }

  /**
   * 3.1.1.14 删除快照
   * @param body
   * @returns {Promise.<T>}
   */
  deleteSnapshot(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hdfs/deleteSnapshot`, body);
  }

  /**
   *  4.2.1.1  获取hive sql解释语句
   * @param body
   * @returns {Promise.<T>}
   */
  getExplainSql(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getExplainSql`, body);

  }

  /**
   * 3.2.1.1  查询用户的hive资源列表
   * @param body
   * @returns {Promise.<T>}
   */
  getHiveList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getHiveList`, body);
  }

  /**
   * 3.2.1.2  查询hive数据库的所有表
   * @param body
   * @returns {Promise.<T>}
   */
  getTablesList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getTablesList`, body);
  }

  /**
   * 3.2.1.2  查询hive数据库的所有表不分页
   * @param body
   * @returns {Promise.<T>}
   */
  getTablesListNoPage(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getTablesListNoPage`, body);
  }

  /**
   * 查询hive数据库的所有表和所有二级字段
   * @param body
   * @returns {Promise.<T>}
   */
  getTableAndColumnsByName(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getTableAndColumnsByName`, body);
  }

  /**
   * 3.2.1.3  查询表字段列表信息
   * @param body
   * @returns {Promise.<T>}
   */
  getTableColumnsInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getTableColumnsInfo`, body);
  }

  /**
   * 3.2.1.4  查询表分区信息
   * @param body
   * @returns {Promise.<T>}
   */
  getTablePartitionsInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getTablePartitionsInfo`, body);
  }

  /**
   * 3.2.1.7  查看建表语句
   * @param body
   * @returns {Promise.<T>}
   */
  getTableCreateTable(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/showCreateTable`, body);
  }

  /**
   * 3.2.1.5  创建表
   * @param body
   * @returns {Promise.<T>}
   */
  createTableByCreateStr(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/createTableByCreateStr`, body);
  }

  /**
   * 3.2.1.6  删除表
   * @param body
   * @returns {Promise.<T>}
   */
  deleteTable(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/deleteTable`, body);
  }

  /**
   * 3.2.1.7  查询hive query sql列表
   * @param body
   * @returns {Promise.<T>}
   */
  getQuerySql(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getQuerySql`, body);
  }

  /**
   * 3.2.1.7  查询hive query sql列表
   * @param body
   * @returns {Promise.<T>}
   */
  getQueryResult(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getQueryResult`, body);
  }

  /**
   * 3.2.1.8  4.2.1.8  加载hdfs文件到数据表
   * 提交加载数据接口
   * @param body
   * @returns {Promise.<T>}
   */
  loadHdfsFileToHive(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/loadHdfsFileToHive`, body);
  }

  checkLoadHdfsFileToHive(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/checkLoadHdfsFileToHive`, body);
  }

  /**
   * 3.2.1.8  创建hive query sql 保存
   * @param body
   * @returns {Promise.<T>}
   */
  addQuerySql(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/addQuerySql`, body);
  }

  /**
   * 3.2.1.9  删除hive query sql
   * @param body
   * @returns {Promise.<T>}
   */
  deleteQuerySql(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/deleteQuerySql`, body);
  }

  /**
   * 3.2.1.10 运行Hive query sql
   * @param body
   * @returns {Promise.<T>}
   */
  runQuerySql(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/runQuerySql`, body);
  }

  /**
   * 3.2.1.11 查询Hive query sql运行历史记录
   * @param body
   * @returns {Promise.<T>}
   */
  getRunQuerySqlHis(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/getRunQuerySqlHis`, body);
  }

  /**
   * 3.2.1.12 查询hive udfs
   * @param body
   * @returns {Promise.<T>}
   */
  udfsGet(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/udfs/get`, body);
  }

  /**
   * 3.2.1.13 创建hive udfs
   * @param body
   * @returns {Promise.<T>}
   */
  udfsAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/udfs/add`, body);
  }

  /**
   * 验证Udfs 唯一
   * @param body
   * @returns {*}
   */
  validateNameAndDbName(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/udfs/validateNameAndDbName`, body);
  }


  /**
   * 3.2.1.14 删除hive udfs
   * @param body
   * @returns {Promise.<T>}
   */
  udfsDelete(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/udfs/delete`, body);
  }

  /**
   * 3.2.1.15 修改hive udfs
   * @param body
   * @returns {Promise.<T>}
   */
  udfsUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hive/udfs/update`, body);
  }

  /**
   * 4.3.1.1  获取namespace
   * @param body
   */
  listNameSpace(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/listNameSpace`, body);
  }

  /**
   * 3.3.1.1  创建表
   * @param body
   * @returns {Promise.<T>}
   */
  tableCreate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/create`, body);
  }

  /**
   * 4.3.1.2  禁用表
   * @param body
   * @returns {Promise.<T>}
   */
  disable(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/disable`, body);
  }

  /**
   * 4.3.1.3  启用表
   * @param body
   * @returns {Promise.<T>}
   */
  enable(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/enable`, body);
  }

  dropTable(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/drop`, body);
  }

  /**
   * 3.3.1.2  查询单个表的信息
   * @param body
   * @returns {Promise.<T>}
   */
  descTable(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/descTable`, body);
  }

  /**
   * 3.3.1.3  查询hbase的表列表
   * @param body
   * @returns {Promise.<T>}
   */
  listTables(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/listTables`, body);
  }

  /**
   * 3.3.1.3  查询hbase的表列表
   * @param body
   * @returns {Promise.<T>}
   */
  listNameSpaceFromLocal(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hbase/listNameSpaceFromLocal`, body);
  }

  /**
   * 3.3.1.4  根据rowkey范围查询
   * @param body
   * @returns {Promise.<T>}
   */
  getByRowkey(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/getByRowkey`, body);
  }

  /**
   * 3.3.1.5  根据rowkey修改列值
   * @param body
   * @returns {Promise.<T>}
   */
  updateByRowkey(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/updateByRowkey`, body);
  }

  /**
   * 3.3.1.6  根据rowkey删除列
   * @param body
   * @returns {Promise.<T>}
   */
  deleteColumnByRowkey(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/deleteColumnByRowkey`, body);
  }

  /**
   * 3.3.1.7  根据rowkey修改列
   * @param body
   * @returns {Promise.<T>}
   */
  updateColumnByRowkey(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/updateColumnByRowkey`, body);
  }

  /**
   * 3.3.1.7  根据rowkey增加列
   * @param body
   * @returns {Promise.<T>}
   */
  addColumnByRowkey(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/addColumnByRowkey`, body);
  }

  /**
   * 3.3.1.8  根据rowkey增加一行记录
   * @param body
   * @returns {Promise.<T>}
   */
  addRowByRowkey(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/addByRowkey`, body);
  }

  /**
   * 3.3.1.9  根据rowkey删除一行
   * @param body
   * @returns {Promise.<T>}
   */
  deleteRowByRowkey(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/hbase/table/deleteByRowkey`, body);
  }

  /**
   * 4.4.1.1  查询用户的HIVE APP列表
   * @param body
   * @returns {Promise.<T>}
   */
  getHiveAppList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/hive/getByAppId`, body);
  }


  /**
   * 4.4.1.1  查询用户的YARN APP列表
   * @param body
   * @returns {Promise.<T>}
   */
  getAppList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getAppList`, body);
  }

  /**
   * 4.4.1.2  查询用户的YARN APP列表
   * @param body
   * @returns {Promise.<T>}
   */
  getAppInfoByAppID(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getAppInfoByAppID`, body);
  }

  /**
   * 4.4.1.3  查询用户的YARN QUEUE列表
   * @param body
   * @returns {Promise.<T>}
   */
  getQueueList(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getQueueList`, body);
  }

  /**
   * 4.4.1.3  查询用户的YARN QUEUE列表 任务管理，数据稽核使用该接口查询
   * @param body
   * @returns {Promise.<T>}
   */
  getQueueListByUserId(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getQueueListByUserId`, body);
  }

  /**
   * 查询用户的YARN QUEUE列表 角色管理-用户权限使用
   * @param body
   * @returns {Promise.<T>}
   */
  getQueueByTennatId(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/yarn/getQueueByTennatId`, body);
  }


  /**
   * 4.4.1.4  查询集群APP汇总的信息
   * @param body
   * @returns {Promise.<T>}
   */
  getClusterMetrics(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getClusterMetrics`, body);
  }

  /**
   * 4.4.1.5  查询用户的YARN APP的history页面
   * @param body
   * @returns {Promise.<T>}
   */
  getHistory(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getHistory`, body);
  }

  getWorkflowByJobId(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/workflow/getByJobId`, body);
  }

  cronValid(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/cronValid`, body);
  }

  auditDetail(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/detail/get`, body);
  }

  auditGetDesc(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/detail/getDesc`, body);
  }


  /**
   * 4.1.1.1  任务查询
   * @param body
   * @returns {*}
   */
  getTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/get`, body);
  }

  batchDownload(body) {
    return Vue.http.post(`${C.APIURL}bdpmng/service/task/batch/download`, body, {
      headers: C.HEADERS,
      _timeout: 15000,
      onTimeout: (request) => {
        NProgress.done();
        Message({
          type: 'error',
          message: `请求超时`
        });
      }
    })

    /*let url = `${C.APIURL}bdpmng/service/task/batch/download`;
     Vue.http.get(url, {
     headers: C.HEADERS,
     _timeout: 3000,
     onTimeout: (request) => {
     Message({
     type: 'error',
     message: `请求超时`
     });
     }
     }).then(res => {
     if (res.body.type != 'application/zip') {
     Message({
     type: 'error',
     message: res.body.retMsg
     });
     return false;
     }
     util.downloadFile('task.zip', res.body)
     });*/

  }


  /**
   * 4.1.1.2  创建spark任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskSparkAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/spark/add`, body,);
  }

  /**
   * 4.1.1.3  创建Map Reduce任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskMrAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/mr/add`, body,);
  }

  /**
   * 4.1.1.4  创建hive任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskHiveAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/hive/add`, body,);
  }

  /**
   * 4.1.1.5  创建sqoop任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskSqoopAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/sqoop/add`, body,);
  }

  /**
   * 4.1.1.6  创建shell任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskShellAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/shell/add`, body,);
  }

  /**
   * 5.1.1.8  创建pytohon任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskPythonAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/python/add`, body,);
  }

  /**
   * 4.1.1.7  创建工作流任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskWorkflowAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/workflow/add`, body,);
  }

  /**
   * 5.1.1.10  编辑spark任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskSparkUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/spark/update`, body,);
  }

  /**
   * 5.1.1.11  编辑Map Reduce任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskMrUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/mr/update`, body,);
  }

  /**
   * 5.1.1.12  编辑hive任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskHiveUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/hive/update`, body,);
  }

  /**
   * 5.1.1.13  编辑sqoop任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskSqoopUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/sqoop/update`, body,);
  }

  /**
   * 5.1.1.14  编辑shell任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskShellUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/shell/update`, body,);
  }

  /**
   *
   * @param body
   * @returns {Promise.<T>}
   */
  taskPythonUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/python/update`, body,);
  }

  /**
   * 5.1.1.15  编辑工作流任务模板
   * @param body
   * @returns {Promise.<T>}
   */
  taskWorkflowUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/workflow/update`, body,);
  }

  /**
   * 4.1.1.15  启动任务
   * @param body
   */
  startTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/start`, body,);
  }

  /**
   * 4.1.1.8  删除任务模板
   * @param body
   */
  deleteTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/delete`, body,);
  }

  /**
   * 4.1.1.16  停止任务
   * @param body
   * @returns {Promise.<T>}
   */
  stopTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/stop`, body,);
  }

  enableTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/enable`, body,);
  }

  diableTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/disable`, body,);
  }

  downloadLog(body,task8){
    let url = `${C.APIURL}bdpmng/service/tasktbl/downloadLog`;
    if(task8) url = `${C.APIURL}bdpmng/service/audit/task/downloadLog`;
    Vue.http.post(url,body, {
      headers: C.HEADERS,
      _timeout: 3000,
      onTimeout: (request) => {
        Message({
          type: 'error',
          message: `请求超时`
        });
      }
    }).then(res => {
      if (res.body.type != 'application/octet-stream') {
        Message({
          type: 'error',
          message: res.body.retMsg
        });
        return false;
      }
      util.downloadFile(`${body.task_id}.log`, res.body)
    });
  }

  //数据质量稽核

  //一次性任务，开始
  startAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/start`, body,);
  }

  //一次性任务，停止
  stopAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/stop`, body,);
  }

  //定时任务，启用
  enableAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/enable`, body,);
  }

  //定时任务，禁用
  disableableAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/disable`, body,);
  }

  //获取数据质量稽核日志
  getAuditTaskLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/getLog`, body,);
  }

  /**
   * 5.1.1.22  根据任务id查询任务详情
   * @param body
   * @returns {Promise.<T>}
   */
  getByTaskID(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/getByTaskID`, body);
  }

  /**
   * 4.2.1.1  查询数据源
   * @param body
   * @returns {Promise.<T>}
   */
  getDatasource(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/datasource/get`, body,);
  }

  getTrackingLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getTrackingLog`, body,);
  }

  getFullTrackingLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getFullTrackingLog`, body,);
  }

  getYarnLogByFullPath(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getYarnLogByFullPath`, body,);
  }

  getTaskAttemptLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getTaskAttemptLog`, body,);

  }

  getTaskAttemptRunLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getTaskAttemptRunLog`, body,);
  }

  getTezByTaskID(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/getTezByTaskID`, body,);
  }

  /*
   任务分组
   */
  getTaskgroup(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/taskgroup/get`, body,);
  }
  validateTaskGroupName(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/taskgroup/validateTaskGroupName`, body,);
  }
  getlistTaskgroup(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/taskgroup/getlist`, body,);
  }

  taskgroupAdd(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/taskgroup/add`, body,);
  }

  taskgroupUpdate(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/taskgroup/update`, body,);
  }

  taskgroupDelete(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/taskgroup/delete`, body,);
  }


  /**
   * 4.2.1.1  测试数据源
   * @param body
   * @returns {Promise.<T>}
   */
  testDatasource(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/datasource/testConnection`, body,);
  }

  /**
   * 4.2.1.2  创建数据源
   * @param body
   * @returns {Promise.<T>}
   */
  addDatasource(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/datasource/add`, body,);
  }

  /**
   * 4.2.1.1  修改数据源
   * @param body
   * @returns {Promise.<T>}
   */
  updateDatasource(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/datasource/update`, body,);
  }

  /**
   * 4.2.1.3  删除数据源
   * @param body
   * @returns {Promise.<T>}
   */
  deleteDatasource(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/datasource/delete`, body,);
  }

  /**
   * 5.1.1.1  查询功能权限
   * @param body
   * @returns {*}
   */
  getFuncGet(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege /func/get`, body,);
  }

  /**
   * 5.1.1.2  编辑功能权限
   * @param body
   * @returns {*}
   */
  getFuncSave(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/func/save`, body,);
  }

  /**
   *  数据源管理数据名称是否唯一
   * @param body
   * @returns {*}
   */
  validateDatasourceName(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/datasource/validateDatasourceName`, body,);
  }

  /**
   * 5.1.1.17  查询任务运行记录列表
   * @param body
   * @returns {*}
   */
  getTaskDetail(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/task/detail/get`, body);
  }


  /**
   * 2.1.1.1  查询角色信息
   * @param body
   * @returns {*}
   */
  getRoleGet(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/role/get`, body);
  }

  /**
   * 2.1.1.2 新增角色
   * @param body
   * @returns {*}
   */
  addRole(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/role/add`, body);
  }

  /**
   * 2.1.1.3 编辑增角色
   * @param body
   * @returns {*}
   */
  updateRole(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/role/edit`, body);
  }

  getValidateRole(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/role/validate`, body);
  }

  /**
   * 2.1.1.4 删除角色
   * @param body
   * @returns {*}
   */
  deleteRole(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/role/delete`, body);
  }

  /**
   * 2.1.2.1 查询角色功能列表
   * @param body
   * @returns {*}
   */
  getRoleFunc(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/func/get`, body);
  }

  /**
   * 2.1.2.1 保存角色功能设置
   * @param body
   * @returns {*}
   */
  saveRoleFunc(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/func/save`, body);
  }

  /**
   * 2.1.3.1 查询所有数据权限
   * @param body
   * @returns {*}
   */
  getPrivDatas(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/data/serv/get`, body);
  }

  /**
   * 2.1.3.1 查询hdfs数据权限
   * @param body
   * @returns {*}
   */
  getHdfsPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hdfs/policy/getacls`, body);
  }

  /**
   * 2.1.3.1 查询hbase数据权限
   * @param body
   * @returns {*}
   */
  getHbasePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hbase/policy/getacls`, body);
  }

  /**
   * 2.1.3.1 查询hive数据权限
   * @param body
   * @returns {*}
   */
  getHivePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hive/policy/getacls`, body);
  }

  /**
   * 2.1.3.1 查询yarn数据权限
   * @param body
   * @returns {*}
   */
  getYarnPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/yarn/policy/getacls`, body);
  }


  sparkHisInof(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/sparkinfo`, body);
  }

  getMrJobInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getMrJobInfo`, body);
  }

  getMrJobAttemptsTasks(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getMrJobAttemptsTasks`, body);
  }

  getMrJobAttemptTaskAttempt(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getMrJobAttemptTaskAttempt`, body);
  }

  getApplicationJobInfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getApplicationJobInfo`, body);
  }

  getApplicationJobInfoDetail(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getApplicationJobInfoDetail`, body);
  }

  getApplicationJobTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getApplicationJobTask`, body);
  }

  getApplicationJobTaskAttempt(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/datamgt/yarn/getApplicationJobTaskAttempt`, body);
  }

  oozieJobinfo(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/oozie/jobinfo`, body);
  }

  getJobDefinition(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/oozie/getJobDefinition`, body);
  }

  getJobLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/oozie/getJobLog`, body);
  }

  getJobErrorLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/oozie/getJobErrorLog`, body);
  }

  getJobAuditLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/oozie/getJobAuditLog`, body);
  }

  getJobActionRun(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/oozie/getJobActionRun`, body);
  }

  getJobGraph(body) {
    //return this.vPost(`${C.APIURL}bdpmng/service/oozie/getJobGraph`, body);
    let url = `${C.APIURL}bdpmng/service/oozie/getJobGraph`;
    return Vue.http.post(url, body, {
      headers: C.HEADERS,
      _timeout: 3000,
      onTimeout: (request) => {
        Message({
          type: 'error',
          message: `请求超时`
        });
      }
    })
    /* .then(res => {
     if (res.body.type != 'application/zip') {
     Message({
     type: 'error',
     message: res.body.retMsg
     });
     return false;
     }
     }
     );*/
  }


  /**
   * 2.1.3.1 查询kafka数据权限
   * @param body
   * @returns {*}
   */
  getKafkaPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/kafka/policy/getacls`, body);
  }

  /**
   * 2.1.4.1 新增hdfs数据权限
   * @param body
   * @returns {*}
   */
  addHdfsPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hdfs/policy/add`, body);
  }

  /**
   * 2.1.4.2 新增hbase数据权限
   * @param body
   * @returns {*}
   */
  addHbasePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hbase/policy/add`, body);
  }

  /**
   * 2.1.4.3 新增hive数据权限
   * @param body
   * @returns {*}
   */
  addHivePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hive/policy/add`, body);
  }

  /**
   * 2.1.4.4 新增yarn数据权限
   * @param body
   * @returns {*}
   */
  addYarnPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/yarn/policy/add`, body);
  }

  /**
   * 2.1.4.5 新增kafka数据权限
   * @param body
   * @returns {*}
   */
  addKafkaPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/kafka/policy/add`, body);
  }

  /**
   * 2.1.5.1 更新hdfs数据权限
   * @param body
   * @returns {*}
   */
  updateHdfsPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hdfs/policy/update`, body);
  }

  /**
   * 2.1.5.2 更新hbase数据权限
   * @param body
   * @returns {*}
   */
  updateHbasePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hbase/policy/update`, body);
  }

  /**
   * 2.1.5.3 更新hive数据权限
   * @param body
   * @returns {*}
   */
  updateHivePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hive/policy/update`, body);
  }

  /**
   * 2.1.5.4 更新yarn数据权限
   * @param body
   * @returns {*}
   */
  updateYarnPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/yarn/policy/update`, body);
  }

  /**
   * 2.1.5.5 更新kafka数据权限
   * @param body
   * @returns {*}
   */
  updateKafkaPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/kafka/policy/update`, body);
  }

  /**
   * 2.1.6.1 删除hdfs数据权限
   * @param body
   * @returns {*}
   */
  deleteHdfsPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hdfs/policy/delete`, body);
  }

  /**
   * 2.1.6.2 删除hbase数据权限
   * @param body
   * @returns {*}
   */
  deleteHbasePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hbase/policy/delete`, body);
  }

  /**
   * 2.1.6.3 删除hive数据权限
   * @param body
   * @returns {*}
   */
  deleteHivePolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/hive/policy/delete`, body);
  }

  /**
   * 2.1.6.4 删除yarn数据权限
   * @param body
   * @returns {*}
   */
  deleteYarnPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/yarn/policy/delete`, body);
  }

  /**
   * 2.1.6.5 删除kafka数据权限
   * @param body
   * @returns {*}
   */
  deleteKafkaPolicy(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/kafka/policy/delete`, body);
  }

  /**
   * 校验策略名是否重复
   */
  judgePolicyName(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/data/policy/judgePolicyName`, body);
  }

  /**
   * 获取数据权限 kafka Topic列表
   */
  getKafkaTopics(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/priv/kafka/policy/getKafkaTopics`, body);
  }

  /**
   * 2.2.1.1 查询用户列表
   * @param body
   * @returns {*}
   */
  getUser(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/user/get`, body);
  }

  getValidateUser(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/user/validate`, body);
  }

  /**
   * 2.2.1.2 新增用户
   * @param body
   * @returns {*}
   */
  addUser(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/user/add`, body);
  }

  /**
   * 2.2.1.3 修改用户
   * @param body
   * @returns {*}
   */
  updateUser(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/user/edit`, body);
  }

  /**
   * 2.2.1.4 删除用户
   * @param body
   * @returns {*}
   */
  deleteUser(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/privilege/user/delete`, body);
  }

  /**
   * 2.2.1.6  获取系统配置项列表
   * @param body
   * @returns {Promise.<T>}
   */
  getconfig(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/user/getconfig`, body);
  }

  /**
   * 6.3.1.1 创建稽查任务
   * @param body
   * @returns {Promise.<T>}
   */
  addAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/add`, body);
  }

  /**
   * 6.3.1.2  查询稽查任务
   * @param body
   * @returns {*}
   */
  getAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/get`, body);
  }

  /**
   * 6.3.1.3 验证稽核任务名称是否存在
   * @param body
   * @returns {*}
   */
  validateAuditTaskName(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/validateAuditTaskName`, body);
  }

  /**
   * 6.3.1.3  修改稽查任务
   * @param body
   * @returns {Promise.<T>}
   */
  updateAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/update`, body);
  }

  /**
   * 6.3.1.4  删除稽查任务
   * @param body
   * @returns {*}
   */
  deleteAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/delete`, body);
  }

  /**
   * 6.4.1.1  启动稽查任务
   * @param body
   * @returns {*}
   */
  startAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/start`, body);
  }

  /**
   * 6.4.1.1  停止稽查任务
   * @param body
   * @returns {*}
   */
  stopAuditTask(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/task/stop`, body);
  }

  /**
   * 7.1.1.1 查看审计日志
   * @param body
   * @returns {*}
   */
  getAuditLog(body) {
    return this.vPost(`${C.APIURL}bdpmng/service/audit/log/get`, body);
  }
}
export default new Dao()

